﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.popups.achievement {
    import reprise.ui.*;
    import flash.events.*;
    import reprise.controls.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.vo.*;
    import net.wooga.pets.views.popups.*;
    import net.wooga.pets.constants.*;
    import net.wooga.pets.utils.*;

    public class AchievementReachedPopupMediator extends AbstractPopupMediator {

        override public function onRegister():void{
            super.onRegister();
            var _local1:RewardVO = RewardVO(this.view.data);
            RepriseUtils.addLabel(this.view, "title showcardGothicFontOutline", this.getTitleLabel(_local1));
            RepriseUtils.addComponent(this.view, ("rewardGraphic " + _local1.achievementVO.id));
            RepriseUtils.addLabel(this.view, "copy myriadProFont", this.getCopyLabel(_local1));
            RepriseUtils.addLabel(this.view, "hint myriadProFont", language.getTextByKey("achievement_reached_text2"));
            this.addOkButton("achievement_reached_button");
            dispatch(new InfoEvent(EventConstants.PLAY_EFFECT_SOUND, GameConstants.SOUND_SOLVE_MISSION));
        }
        override protected function close():void{
            super.close();
            this.track({st2:"close"});
        }
        override protected function addOkButton(_arg1:String, _arg2:UIComponent=null):void{
            var _local3:LabelButton = createOkButton(_arg1, _arg2);
            eventMap.mapListener(_local3, MouseEvent.CLICK, this.onOk);
            RepriseUtils.addComponent(_local3, "bookIcon");
        }
        override protected function onOk(_arg1:MouseEvent):void{
            this.close();
            dispatch(new InfoEvent(EventConstants.CREATE_POPUP, GameConstants.ACHIEVEMENT_BOOK_POPUP));
            this.track({st2:"ok"});
        }
        private function get view():AchievementReachedPopup{
            return (AchievementReachedPopup(viewComponent));
        }
        private function getTitleLabel(_arg1:RewardVO):String{
            var _local2:String = language.getTextByKey(("achievement_" + _arg1.medal));
            return (language.getTextByKey("achievement_reached_title", {medal:_local2}));
        }
        private function getCopyLabel(_arg1:RewardVO):String{
            var _local2:String = language.getTextByKey("achievement_reached_text");
            _local2 = (_local2 + "<br/>");
            _local2 = (_local2 + language.getTextByKey(("achievement_reached_" + _arg1.achievementVO.id), {amount:_arg1.pointsNeeded}));
            return (_local2);
        }
        override protected function track(_arg1:Object):void{
            var _local2:Object = new Object();
            _local2.type = "achievements";
            _local2.st1 = "popup_reached";
            _local2.st2 = _arg1.st2;
            dispatch(new TrackingEvent(TrackingConst.TRACK, TrackingConst.EVENT, _local2));
        }

    }
}//package net.wooga.pets.views.popups.achievement 
